package com.fulin.spring.beans;

import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;

public class Context {
    private AtomicInteger count = new AtomicInteger();

    public void inc(){
        count.incrementAndGet();
    }

    public void dec(){
        //模拟数据查询文件生成操作
        Random random = new Random();
        try {
            Thread.sleep(random.nextInt(1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        count.decrementAndGet();
//        System.out.println("减一成功");
    }

    public int get(){
        return count.get();
    }
}
